package com.org.salesforce;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;

public class MainActvity extends Activity {
    /** Called when the activity is first created. */
	Button b;
	ListView lv ;
	
	public static MainActvity mactivity;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        mactivity = this;
        
        //lv = (ListView) findViewById(R.id.listView);
        b = (Button) findViewById(R.id.button);
        b.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {          
				Http_Url_Class async_1 = new Http_Url_Class();
				String url ="https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=3MVG9Y6d_Btp4xp7cR8CojsxTiBr_9UW3fECjHAvBu6.5I8clKBfHxt_ddTSOD7RZJb8LWGEeQDjP2V2GEhRR&client_secret=2708733805985228160&username=chandras.android@gmail.com&password=appshark@321YZnHzzSua71ebszjmJ4ufiez";
				async_1.execute(url,"Login");
			}
		});
        
        
    }
    
    @Override
    protected void onUserLeaveHint() {
     	Log.i("NCS","Home is clicked");  
    	super.onUserLeaveHint();
    }
    public void retriveData(View v){
    	
    	try{
			//String contacts = "select id,name,Required__c,Field_Label__c,Data_Type__c,Field_Length__c,SFDC_Required__c from Form_Fields__c where form__c='a1ZC0000000SQe8MAG' order by createddate";
			//String contacts = "Select Name from Agility__c";                   
    		Http_Url_Class async_2 = new Http_Url_Class();              
			//String instanceUrl = Session.sInstanceUrl+"/services/data/v26.0/sobjects/Agility__c/";
    		String instanceUrl = Session.sInstanceUrl+"/services/data/v26.0/query/?q=Select+Id,LastName,Company,Email+from+Lead";
			Log.i("NCS","instanceUrl  is   :"+instanceUrl);
			async_2.execute(instanceUrl,"retrive");               
			
			}catch (Exception e) {
				// TODO: handle exception
				Log.i("TPT","Exception is  :"+e.getMessage());
			}              
    }
	
    
   
}